import request from "@/utils/request";

export async function queryList(
  params: {
    // query
    /** current */
    current?: number;
    /** pageSize */
    pageSize?: number;
  },
  options?: { [key: string]: any },
) {
  const res = await request('/menu', {
    method: 'GET',
    ...(options || {}),
  });
  console.log('res.data',res.data)
  return {
    success: res.data && res.data.length >= 0,
    data: res.data ?? [],
  }
}

export async function allMenuByTId(params: {
  tId: string;
  flat?: boolean
}, options?: { [key: string]: any }) {
  return request('/menu/teacher/' + params.tId, {
    method: 'GET',
    params: {
      flat: params.flat
    },
    ...(options || {}),
  });
}


export async function add(
  body?: Partial<API.MenuType>,
  options?: { [key: string]: any },
) {
  return request('/menu', {
    method: 'POST',
    data: body,
    ...(options || {}),
  });
}


export async function modify(
  body?: Partial<API.MenuType>,
  options?: { [key: string]: any },
) {
  return request(`/menu`, {
    method: 'PUT',
    data: body,
    ...(options || {}),
  });
}

